class Solution(object):
    def findSolution(self, customfunction, z):
        """
        :type num: int
        :type z: int
        :rtype: List[List[int]]
        """
        F = customfunction
        right = 1000
        out = []
        for x in range(1, 1001):
            left = 1
            if right < 1:
                break
            while left < right:
                mid = (left + right) // 2
                if F.f(x, mid) == z:
                    right = mid
                    break
                else:
                    if F.f(x, mid) < z:
                        left = mid + 1
                    else:
                        right = mid
            if F.f(x, right) == z:
                out.append([x, right])
                right -= 1
        return out